#!/usr/bin/env python
# -*- coding:utf-8 -*-


def dicts01():
    city_code = {'suzhou': '0512', 'beijing': '011', 'shanghai': '012', 'tangshan': '0315'}
    print len(city_code)
    print city_code['suzhou']
    city_code['xian'] = '029'
    print city_code
    print " Suzhou is a beautiful city, its area code is %(suzhou)s" % city_code
    del city_code['beijing']
    print city_code


def dicts02():
    d1 = {"lang": "python"}
    d2 = {"song": "I dreamed a dream"}
    d1.update(d2)
    print d1
    if d1.has_key("lang"):
        print True
    print d1.keys()
    print d1.values()


def sortdicts():
    city_code = {'suzhou': '0512', 'beijing': '011', 'shanghai': '012', 'tangshan': '0315'}
    print city_code.__getitem__
    print sorted(city_code, key=city_code.__getitem__, reverse=True)


if __name__ == '__main__':
    dicts01()
    print "-" * 60
    dicts02()
    print "-" * 60
    sortdicts()
